//
//  CCForumPicture.m
//  CwinCar
//
//  Created by dlios on 15/10/23.
//  Copyright © 2015年 dlios. All rights reserved.
//

#import "CCForumPicture.h"

@implementation CCForumPicture

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
- (instancetype)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame]) {
        [self creatControll];
    }
    return self;
}
- (void)creatControll
{
    _array = [[NSMutableArray alloc]init];
    self.imageView  = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, mainScreen_Width, 100 * suitableScreen_Height)];
    [self.imageView setImage:[UIImage imageNamed:@"lanse"]];
    [self addSubview:self.imageView];
    self.bigTitle = [[UILabel alloc]initWithFrame:CGRectMake(20, 30, 160 * suitableScreen_Width, 30 * suitableScreen_Height)];
    self.bigTitle.textColor = [UIColor whiteColor];
    self.bigTitle.font = [UIFont systemFontOfSize:22];
    [self.imageView addSubview:self.bigTitle];
    self.lable =[[UILabel alloc]initWithFrame:CGRectMake(200 * suitableScreen_Width, 15 * suitableScreen_Height, 60 * suitableScreen_Width, 20 * suitableScreen_Height)];
    self.lable.textColor = [UIColor whiteColor];
    self.lable.font = [UIFont systemFontOfSize:16];
    [self.imageView addSubview:self.lable];
    self.lable.text = @"版主:";
    self.secondLable = [[UILabel alloc]initWithFrame:CGRectMake(200 * suitableScreen_Width,40 * suitableScreen_Height, 60 * suitableScreen_Width, 20 * suitableScreen_Height)];
    self.secondLable.textColor = [UIColor whiteColor];
    [self.imageView addSubview:self.secondLable];
    self.secondLable.font = [UIFont systemFontOfSize:16];
    self.secondLable.text = @"主题:";
    self.thirfLable =[[UILabel alloc]initWithFrame:CGRectMake(200 * suitableScreen_Width, 65 * suitableScreen_Height, 60 * suitableScreen_Width, 20 * suitableScreen_Height)];
    self.thirfLable.text = @"帖子:";
    [self.imageView addSubview:self.thirfLable];
    self.thirfLable.font = [UIFont systemFontOfSize:16];
    self.thirfLable.textColor = [UIColor whiteColor];
    for (int i = 0; i < 3; i++) {
        self.titleLable = [[UILabel alloc]initWithFrame:CGRectMake(245 * suitableScreen_Width , 15 * suitableScreen_Height + i * 25 , 120 * suitableScreen_Width, 20 * suitableScreen_Height)];
        [self.imageView addSubview:self.titleLable];
        [self.titleLable setFont:[UIFont systemFontOfSize:16]];
        self.titleLable .textColor = [UIColor whiteColor];
        [_array addObject:self.titleLable];
    }
    
}
- (void)setDataModel:(NSMutableArray *)arry
{
    CCForumButtonModel *model = [[CCForumButtonModel alloc]init];
    if (arry.count == 4) {
        for (int i = 0; i < 4; i ++) {
            model = [arry objectAtIndex:0];
            NSString *str = model.moderatorName;
            model = [arry objectAtIndex:1];
            NSString *string = model.moderatorName;
            NSString *titlStr = [str stringByAppendingString:string];
            UILabel *lable = [_array objectAtIndex:0];
            lable.text = titlStr;
            UILabel *themeLable = [_array objectAtIndex:1];
            themeLable.text =[arry objectAtIndex:2];
            UILabel *postNumLable = [_array objectAtIndex:2];
            postNumLable.text = [arry objectAtIndex:3];
            
        }
    }else if (arry.count == 3)
    {
        for (int i = 0; i < 3; i ++) {
            model = [arry objectAtIndex:0];
            NSString *str = model.moderatorName;
            UILabel *lable = [_array objectAtIndex:0];
            lable.text = str;
            UILabel *themeLable = [_array objectAtIndex:1];
            themeLable.text =[arry objectAtIndex:1];
            UILabel *postNumLable = [_array objectAtIndex:2];
            postNumLable.text = [arry objectAtIndex:2];
        }
    }else if (arry.count == 5)
    {
        for (int i = 0; i < 4; i++) {
            
            model = [arry objectAtIndex:0];
            NSString *str = model.moderatorName;
            model = [arry objectAtIndex:1];
            NSString *string = model.moderatorName;
            model =[arry objectAtIndex:2];
            NSString *thirStr = model.moderatorName;
            NSString *fourtStr = [str stringByAppendingString:string];
            NSString *fiveStr = [fourtStr stringByAppendingString:thirStr];
            UILabel *lable = [_array objectAtIndex:0];
            lable.text = fiveStr;
            UILabel *themeLable = [_array objectAtIndex:1];
            themeLable.text =[arry objectAtIndex:3];
            UILabel *postNumLable = [_array objectAtIndex:2];
            postNumLable.text = [arry objectAtIndex:4];
        }
    }
    else  if (arry.count == 2) {
        for (int i = 0; i < 3; i ++) {
            UILabel *lable = [_array objectAtIndex:0];
            lable.text = @"无";
            UILabel *themeLable = [_array objectAtIndex:1];
            themeLable.text =[arry objectAtIndex:0];
            UILabel *postNumLable = [_array objectAtIndex:2];
            postNumLable.text = [arry objectAtIndex:1];
        }
    }
}
@end
